package smartcampus.scjava.controller.third;

import org.springframework.web.bind.annotation.*;
import smartcampus.scjava.config.Result;
import smartcampus.scjava.service.XinzitongjiService;
import smartcampus.scjava.service.XueshengService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/view")
public class viewController {

    @Resource
    private XueshengService xueshengService;
    @Resource
    private XinzitongjiService xinzitongjiService;

    @GetMapping("/bie")
    public Result bie(){
        //查询已就业的学生的数量
        int employedCount = xueshengService.findEmployedStudents().size();
        //查询未就业的学生的数量
        int unemployedCount = xueshengService.findUnemployedStudents().size();
        Map<String,Integer> map = new HashMap<>();
        map.put("employedCount",employedCount);
        map.put("unemployedCount",unemployedCount);
        return Result.success(map);
    }

    @GetMapping("/bar")
    public Result bar(){
        //查询出所有
        List<String> counts = new ArrayList<>();
        counts.add(xinzitongjiService.findAllXinzi().toString());
        counts.add(xinzitongjiService.findAllNum().toString());
        //将count中的两个数据转换成map
        Map<String, String> map = new HashMap<>();
        map.put("xAxis", counts.get(0));
        map.put("yAxis", counts.get(1));
        return Result.success(map);
    }
}
